﻿// EXP0123.cpp : 编写程序，读取多条销售记录，并统计每个 ISBN（每本书）有几条销售记录。
//

#include <iostream>
#include "Sales_item.h"
using namespace std;

int main()
{
    cout << "输入多个相同 ISBN 的实例" << endl;
    Sales_item total, trans;
    int cnt;
    if (cin >> total)
    {
        cnt = 1;
        while (cin >> trans)
        {
            if (total.isbn() == trans.isbn())
            {
                total += trans;
                ++cnt;
            }
            else
            {
                cout << "前项合并同类项合计为：" << endl;
                cout << total.isbn() << "出现了" << cnt << "次" << endl;
                total = trans;
                cnt = 1;
            }
        }
        cout << total.isbn() << "出现了" << cnt << "次" << endl;
    }
    else
    {
        cerr << "无数据，退出程序" << endl;
        return -1;
    }
    return 0;
}